package com.qfmy.controller.assistant;

import com.qfmy.service.assistant.InterviewService;
import common.result.Result;
import jakarta.annotation.Resource;
import model.entity.assistant.Interview;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import reactor.core.publisher.Flux;

/**
 * @author 清风明月
 * @Package com.qfmy.controller.assistant
 * @date 2025/5/19
 * @description 面试
 */
@RestController
@SuppressWarnings("all")
@RequestMapping("/app/interview")
public class InterviewController {

    /**
     * 注入sercie
     */
    @Resource
    private InterviewService interviewService;

    /**
     * 保存简历
     */
    @PostMapping("/saveResume")
    public Result saveResume(@RequestBody Interview interview) {
        interviewService.saveResume(interview);
        return Result.ok();
    }

    /**
     * 判断是否上传了简历
     */
    @GetMapping("/isUpload")
    public Result getResume() {
        Boolean resume = interviewService.getResume();
        return Result.ok(resume);
    }

    /**
     * 对话面试
     */
    @GetMapping(value = "/getResume", produces = MediaType.TEXT_PLAIN_VALUE)
    public Flux<String> interview(@RequestParam String prompt, @RequestParam(required = false) Boolean isOne) {
        return interviewService.interview(prompt, isOne);
    }

    /**
     * 语音对话
     */
    @GetMapping(value = "/getResume/voice")
    public Result interviewVoice(@RequestParam String prompt, @RequestParam(required = false) Boolean isOne) {
        return Result.ok(interviewService.interviewVoice(prompt, isOne));
    }

}
